﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace SacMauVN
{
    public partial class UCContent : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //LoadListBlock();
            LoadKinhDoanhXD();
            LoadKinhDoanhTM();
        }

        private void LoadKinhDoanhTM()
        {
            string sql = "SELECT TOP 8 * FROM dbo.tblSMVNSanPham WHERE Extend1 = 0";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            rptListProductTM.DataSource = dt;
            rptListProductTM.DataBind();
        }

        private void LoadKinhDoanhXD()
        {
            string sql = "SELECT TOP 8 * FROM dbo.tblSMVNSanPham WHERE Extend1 = 1";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            rptListProductXD.DataSource = dt;
            rptListProductXD.DataBind();
        }

        private void LoadListBlock()
        {
            string sql = "SELECT * FROM dbo.tblSMVNMenu WHERE IsShowUp = 1 AND Level = 2";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            UCProductList list;
            foreach (DataRow item in dt.Rows)
            {
                list = (UCProductList)LoadControl("UCProductList.ascx");
                list.LoadData(Convert.ToInt32(item["ID"]));
                PlaceHolder1.Controls.Add(list);
                list = null;
            }
        }
    }
}